package physics;



import graphics.ParticleSystem.Explosion;

import java.awt.event.ActionEvent;

import physics.Collisions.Collision;
import physics.MovementControl.JumperMovementController;
import viewControllers.CarrotViewController;
import viewControllers.ExplosionViewController;
import viewControllers.ViewControllersFactory;

import common.Math3D;

public class Carrot extends Weapon {
	
	double jumpStrength = 0.5;
	
	public Carrot(){
		ticksToDisappear = 10;
		this.setMovementControler(new JumperMovementController(this));
	}
	
	
	public void impact(Collision c){
		GameObject bumpedInto;	
		if (c.getObj1().equals(this))
			bumpedInto= c.getObj2();
		else
			bumpedInto = c.getObj1();

		switch (c.getType()){
			case CARROT:
				this.exists = false;
				break;
//			case CARROTROBOT:
//				if (((GiantRobot)bumpedInto).inHittingRange(this.getCenter())){
//					this.setGraphicalObject(ViewControllersFactory.createExplosionViewController(this)); 
//				}
//				break;
			case DEFAULT:
//				getMovementControler().restoreLastPosition();
//				getMovementControler().setHasMomentum(false);
//				this.setGraphicalObject(ViewControllersFactory.createExplosionViewController(this)); 
//				dying = true;
				break;
		}
	}

	public void jump(){
		jump(jumpStrength);
	}
	
	private void jump(double strength){
		this.getMovementControler().addMovement(
				Math3D.scalePoint(getUp(), strength));
		this.getMovementControler().addMovement(
				Math3D.scalePoint(getFace(), strength*100));
	}
			
}
